package dtaskboard.entities;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import dtaskboard.client.dto.TaskDTO;
import dtaskboard.client.dto.TaskStatus;

@Entity
public class Task {

  private Long id;
  private String name;
  private Long hours;
  private TaskStatus status;
  private Date finishDate;


  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  public Long getId() {
    return this.id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getName() {
    return this.name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Long getHours() {
    return this.hours;
  }

  public void setHours(Long hours) {
    this.hours = hours;
  }

  @Enumerated(EnumType.STRING)
  public TaskStatus getStatus() {
    return this.status;
  }

  public void setStatus(TaskStatus status) {
    this.status = status;
  }

  public Date getFinishDate() {
    return this.finishDate;
  }

  public void setFinishDate(Date finishDate) {
    this.finishDate = finishDate;
  }

  public TaskDTO toDTO() {
    TaskDTO dto = new TaskDTO();
    dto.setName(this.name);
    dto.setTaskId(this.id);
    dto.setStatus(this.status);
    dto.setHours(this.hours.intValue());
    dto.setFinish(this.finishDate);
    return dto;
  }

}
